package com.example.javapracticaltraining.service.impl;

import com.example.javapracticaltraining.entity.dto.*;
import com.example.javapracticaltraining.entity.pojo.*;
import com.example.javapracticaltraining.service.*;
import com.example.javapracticaltraining.utils.ChatUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
 * @author awking
 * @date 2025/06/30
 */
@Service
public class SmartHealthServiceImpl implements SmartHealthService {
	@Autowired
	ChatUtil aiUtil;

	@Autowired
	private ElderlyService elderlyService;
	@Autowired
	private MedicalRecordService medicalRecordService;
	@Autowired
	private HealthRecordService healthRecordService;
	@Autowired
	private NursingRecordService nursingRecordService;
	@Autowired
	private CareLevelService careLevelService;

	@Autowired
	private AiHealthWarningService aiHealthWarningService;

	@Override
	public String healthQnA(int userId, String question) {
		return aiUtil.chat(question,userId);
	}

	@Override
	public HealthData getElderlyHealthData(Integer elderlyId) {
		// 获取老人基本信息
		Elderly elderly = elderlyService.getById(elderlyId);
		if (elderly == null) {
			return null;
		}

		// 获取护理等级信息
		CareLevel careLevel = careLevelService.getById(elderly.getCareLevelId());

		// 获取健康记录
		List<HealthRecord> healthRecords = healthRecordService.lambdaQuery()
				.eq(HealthRecord::getElderlyId, elderlyId)
				.list();

		// 获取护理记录
		List<NursingRecord> nursingRecords = nursingRecordService.lambdaQuery()
				.eq(NursingRecord::getElderlyId, elderlyId)
				.list();

		// 获取医疗记录
		List<MedicalRecord> medicalRecords = medicalRecordService.lambdaQuery()
				.eq(MedicalRecord::getElderlyId, elderlyId)
				.list();

		// 转换为DTO
		List<HealthRecordDTO> healthRecordDTOs = healthRecords.stream().map(record -> {
			HealthRecordDTO dto = new HealthRecordDTO();
			BeanUtils.copyProperties(record, dto);
			return dto;
		}).collect(Collectors.toList());

		List<NursingRecordDTO> nursingRecordDTOs = nursingRecords.stream().map(record -> {
			NursingRecordDTO dto = new NursingRecordDTO();
			BeanUtils.copyProperties(record, dto);
			return dto;
		}).collect(Collectors.toList());

		List<MedicalRecordDTO> medicalRecordDTOs = medicalRecords.stream().map(record -> {
			MedicalRecordDTO dto = new MedicalRecordDTO();
			BeanUtils.copyProperties(record, dto);
			return dto;
		}).collect(Collectors.toList());

		// 构建HealthData对象
		HealthData healthData = new HealthData();
		healthData.setElderlyId(elderly.getElderlyId());
		healthData.setName(elderly.getName());
		healthData.setGender(elderly.getGender());
		healthData.setAge(elderly.getAge());
		healthData.setLevelName(careLevel != null ? careLevel.getLevelName() : null);
		healthData.setHealthRecords(healthRecordDTOs);
		healthData.setNursingRecords(nursingRecordDTOs);
		healthData.setMedicalRecords(medicalRecordDTOs);

		return healthData;
	}

	@Override
	public List<HealthData> getAllElderlyHealthData() {
		// 获取所有老人
		List<Elderly> elderlyList = elderlyService.list();
		if (elderlyList == null || elderlyList.isEmpty()) {
			return new ArrayList<>();
		}

		// 为每个老人获取健康数据
		return elderlyList.stream()
				.map(elderly -> getElderlyHealthData(elderly.getElderlyId()))
				.filter(healthData -> healthData != null)
				.collect(Collectors.toList());
	}

	@Override
	public List<AiHealthWarning> analyzeHealthRisks() {
		List<HealthData> healthDataList = getAllElderlyHealthData();
		if (healthDataList == null || healthDataList.isEmpty()) {
			return new ArrayList<>();
		}

		List<AiHealthWarning> warningList = new ArrayList<>();

		for (HealthData healthData : healthDataList) {
			// 构建健康数据的描述
			StringBuilder healthDescription = new StringBuilder();
			healthDescription.append("老人基本信息：\n");
			healthDescription.append("ID: ").append(healthData.getElderlyId()).append("\n");
			healthDescription.append("姓名: ").append(healthData.getName()).append("\n");
			healthDescription.append("性别: ").append(healthData.getGender()).append("\n");
			healthDescription.append("年龄: ").append(healthData.getAge()).append("\n");
			healthDescription.append("护理等级: ").append(healthData.getLevelName()).append("\n\n");

			// 添加健康记录信息
			if (healthData.getHealthRecords() != null && !healthData.getHealthRecords().isEmpty()) {
				healthDescription.append("健康记录：\n");
				for (HealthRecordDTO record : healthData.getHealthRecords()) {
					healthDescription.append("测量日期: ").append(record.getMeasureDate()).append("\n");
					healthDescription.append("血压: ").append(record.getBloodPressure()).append("\n");
					healthDescription.append("血糖: ").append(record.getBloodSugar()).append(" mmol/L\n");
					healthDescription.append("心率: ").append(record.getHeartRate()).append(" 次/分钟\n");
					if (record.getNote() != null && !record.getNote().isEmpty()) {
						healthDescription.append("备注: ").append(record.getNote()).append("\n");
					}
					healthDescription.append("\n");
				}
			}

			// 添加医疗记录信息（简化处理，避免使用getter方法）
			if (healthData.getMedicalRecords() != null && !healthData.getMedicalRecords().isEmpty()) {
				healthDescription.append("医疗记录：\n");
				for (MedicalRecordDTO record : healthData.getMedicalRecords()) {
					// 使用toString方法获取所有信息
					healthDescription.append(record.toString()).append("\n\n");
				}
			}

			// 添加护理记录信息
			if (healthData.getNursingRecords() != null && !healthData.getNursingRecords().isEmpty()) {
				healthDescription.append("护理记录：\n");
				for (NursingRecordDTO record : healthData.getNursingRecords()) {
					healthDescription.append("记录时间: ").append(record.getRecordTime()).append("\n");
					healthDescription.append("护理类型: ").append(record.getCareType()).append("\n");
					healthDescription.append("护理内容: ").append(record.getCareContent()).append("\n");
					healthDescription.append("风险评估: ").append(record.getRisk()).append("\n");
					healthDescription.append("\n");
				}
			}

			// 构建AI提示
			String prompt = "请分析以下老人的健康数据，并评估健康风险。\n" +
					"请严格按照以下格式返回结果（不要增加其他字段）：\n" +
					"风险等级：[无风险/低风险/中风险/高风险]\n" +
					"风险类型：[例如：血糖异常、血压异常等]\n" +
					"风险依据：[详细说明判断风险的依据]\n" +
					"建议：[针对风险的具体建议]\n\n" +
					healthDescription.toString();

			// 调用AI助手
			String aiResponse = aiUtil.chat(prompt, healthData.getElderlyId());
			// 解析AI响应
			String riskLevel = extractPattern(aiResponse, "风险等级：([^\\n]+)");
			String riskType = extractPattern(aiResponse, "风险类型：([^\\n]+)");
			String riskBasis = extractPattern(aiResponse, "风险依据：([^\\n]+)");
			String suggestion = extractPattern(aiResponse, "建议：([^\\n]+)");

			// 创建健康风险警告
			AiHealthWarning warning = new AiHealthWarning();
			warning.setElderlyId(healthData.getElderlyId());
			warning.setWarningTime(new Date());
			warning.setWarningLevel(riskLevel);
			warning.setWarningType(riskType);
			warning.setWarningContent(riskBasis);
			warning.setSuggestion(suggestion);

			// 保存到数据库
			aiHealthWarningService.save(warning);
			warningList.add(warning);
		}

		return warningList;
	}

	/**
	 * 从文本中提取匹配模式的内容
	 * @param text 要搜索的文本
	 * @param patternStr 正则表达式模式
	 * @return 匹配的内容，如果没有匹配则返回空字符串
	 */
	private String extractPattern(String text, String patternStr) {
		if (text == null || patternStr == null) {
			return "";
		}

		// 处理特殊情况：风险依据和建议可能是多行内容
		if (patternStr.contains("风险依据") || patternStr.contains("建议")) {
			// 提取标签名称（如"风险依据："或"建议："）
			String label = patternStr.substring(0, patternStr.indexOf("("));

			// 查找标签在文本中的位置
			int labelIndex = text.indexOf(label);
			if (labelIndex == -1) {
				return "";
			}

			// 找到内容的起始位置（标签后）
			int contentStart = labelIndex + label.length();

			// 找到内容的结束位置（下一个标签前或文本结束）
			int contentEnd = text.length();

			// 查找下一个可能的标签
			String[] possibleNextLabels = {"风险等级：", "风险类型：", "风险依据：", "建议："};
			for (String nextLabel : possibleNextLabels) {
				// 跳过当前标签
				if (nextLabel.equals(label)) {
					continue;
				}

				int nextLabelIndex = text.indexOf(nextLabel, contentStart);
				if (nextLabelIndex != -1 && nextLabelIndex < contentEnd) {
					contentEnd = nextLabelIndex;
				}
			}

			// 提取内容并去除首尾空白
			return text.substring(contentStart, contentEnd).trim();
		}

		// 对于其他标签，使用原来的正则表达式方法
		Pattern pattern = Pattern.compile(patternStr);
		Matcher matcher = pattern.matcher(text);

		if (matcher.find()) {
			return matcher.group(1).trim();
		}

		return "";
	}

	/**
	 * 从AI响应中提取特定章节的内容
	 * @param text AI响应文本
	 * @param sectionNumber 章节编号（如"1"、"2"等）
	 * @param sectionTitle 章节标题（如"护理总结"、"日常护理建议"等）
	 * @return 提取的章节内容，如果没有找到则返回空字符串
	 */
	private String extractSectionContent(String text, String sectionNumber, String sectionTitle) {
		if (text == null || sectionNumber == null || sectionTitle == null) {
			return "";
		}

		// 构建章节标题的正则表达式模式
		// 匹配形式如 "1. 护理总结："或"1. 护理总结:"
		String sectionPattern = sectionNumber + "\\.\\s*" + sectionTitle + "[：:]";

		// 查找章节标题在文本中的位置
		Pattern pattern = Pattern.compile(sectionPattern);
		Matcher matcher = pattern.matcher(text);

		if (!matcher.find()) {
			return ""; // 如果找不到章节标题，返回空字符串
		}

		// 找到章节标题的结束位置
		int contentStart = matcher.end();

		// 查找下一个章节的开始位置
		// 匹配形式如 "2. 日常护理建议："或"3. 饮食建议："等
		String nextSectionPattern = "\\d+\\.\\s*[^\\d\\s][^:：]*[：:]";
		Pattern nextPattern = Pattern.compile(nextSectionPattern);
		Matcher nextMatcher = nextPattern.matcher(text);

		// 从当前章节标题之后开始查找下一个章节标题
		nextMatcher.region(contentStart, text.length());

		int contentEnd;
		if (nextMatcher.find()) {
			// 如果找到下一个章节标题，则当前章节内容到下一个章节标题之前结束
			contentEnd = nextMatcher.start();
		} else {
			// 如果没有找到下一个章节标题，则当前章节内容到文本结束
			contentEnd = text.length();
		}

		// 提取章节内容并去除首尾空白
		String content = text.substring(contentStart, contentEnd).trim();

		return content;
	}


	@Override
	public String optimizeCommunication(String originalText, String targetRole) {
		return "";
	}

	@Override
	public String generatePersonalizedCarePlan(ElderProfile elderProfile) {
		// 构建提示词，包含老人的健康状况、护理等级和偏好
		StringBuilder prompt = new StringBuilder();
		prompt.append("请根据以下老人的健康档案、护理等级和偏好，生成一份个性化护理建议方案。\n\n");

		// 基本信息
		prompt.append("【基本信息】\n");
		prompt.append("姓名：").append(elderProfile.getName()).append("\n");
		prompt.append("性别：").append(elderProfile.getGender()).append("\n");
		prompt.append("年龄：").append(elderProfile.getAge()).append("\n");

		// 护理等级
		if (elderProfile.getCareLevel() != null) {
			prompt.append("\n【护理等级】\n");
			prompt.append("等级名称：").append(elderProfile.getCareLevel().getLevelName()).append("\n");
			prompt.append("服务内容：").append(elderProfile.getCareLevel().getServiceContent()).append("\n");
		}

		// 膳食需求
		if (elderProfile.getDietNeed() != null) {
			prompt.append("\n【膳食需求】\n");
			prompt.append("特殊需求：").append(elderProfile.getDietNeed().getSpecialRequirements()).append("\n");
			prompt.append("过敏信息：").append(elderProfile.getDietNeed().getAllergies()).append("\n");
			prompt.append("饮食习惯：").append(elderProfile.getDietNeed().getEatingHabits()).append("\n");
			prompt.append("营养目标：").append(elderProfile.getDietNeed().getNutritionGoals()).append("\n");
			prompt.append("医生建议：").append(elderProfile.getDietNeed().getDoctorAdvice()).append("\n");
		}

		// 医疗记录
		if (elderProfile.getMedicalRecords() != null && !elderProfile.getMedicalRecords().isEmpty()) {
			prompt.append("\n【医疗记录】\n");
			for (MedicalRecordDTO record : elderProfile.getMedicalRecords()) {
				prompt.append("疾病名称：").append(record.getDiseaseName()).append("\n");
				prompt.append("主要症状：").append(record.getMainSymptoms()).append("\n");
				prompt.append("疾病状态：").append(record.getDiseaseStatus()).append("\n");
				prompt.append("治疗方案：").append(record.getTreatmentPlan()).append("\n");
				prompt.append("当前用药：").append(record.getCurrentMedication()).append("\n");
				prompt.append("医生建议：").append(record.getDoctorAdvice()).append("\n\n");
			}
		}

		// 健康记录
		if (elderProfile.getHealthRecords() != null && !elderProfile.getHealthRecords().isEmpty()) {
			prompt.append("\n【健康记录】\n");
			for (HealthRecordDTO record : elderProfile.getHealthRecords()) {
				prompt.append("记录时间：").append(record.getMeasureDate()).append("\n");
				prompt.append("血压：").append(record.getBloodPressure()).append("\n");
				prompt.append("心率：").append(record.getHeartRate()).append("\n");
				prompt.append("血糖：").append(record.getBloodSugar()).append("\n");
				prompt.append("备注：").append(record.getNote()).append("\n\n");
			}
		}

		prompt.append("\n请根据以上信息，生成一份结构化的个性化护理建议方案，包括以下部分：\n");
		prompt.append("1. 护理总结\n");
		prompt.append("2. 日常护理建议\n");
		prompt.append("3. 饮食建议\n");
		prompt.append("4. 活动建议\n");
		prompt.append("5. 康复训练计划\n");
		prompt.append("6. 健康监测要点\n");
		prompt.append("7. 注意事项\n");
		prompt.append("8. 其他建议\n");
		prompt.append("\n请严格遵守要点格式返回，每个要点用数字编号，并用中文冒号分隔，同时要点内容也要严格按照要点返回\n");

		// 调用AI生成护理建议
		String aiResponse = aiUtil.chat(prompt.toString(), elderProfile.getElderlyId());
		// 解析AI响应，构建CarePlan对象
//		CarePlan carePlan = new CarePlan();
//		carePlan.setElderlyId(elderProfile.getElderlyId());
//		carePlan.setElderlyName(elderProfile.getName());
//		if (elderProfile.getCareLevel() != null) {
//			carePlan.setCareLevelName(elderProfile.getCareLevel().getLevelName());
//		}
//		carePlan.setGeneratedDate(new Date());
//
//		// 提取各部分内容
//		String summary = extractSectionContent(aiResponse, "1", "护理总结");
//		String dailyCare = extractSectionContent(aiResponse, "2", "日常护理建议");
//		String dietaryAdvice = extractSectionContent(aiResponse, "3", "饮食建议");
//		String activityRecommendations = extractSectionContent(aiResponse, "4", "活动建议");
//		String rehabilitationPlan = extractSectionContent(aiResponse, "5", "康复训练计划");
//		String healthMonitoring = extractSectionContent(aiResponse, "6", "健康监测要点");
//		String precautions = extractSectionContent(aiResponse, "7", "注意事项");
//		String additionalAdvice = extractSectionContent(aiResponse, "8", "其他建议");
//
//		carePlan.setSummary(summary);
//		carePlan.setDailyCare(dailyCare);
//		carePlan.setDietaryAdvice(dietaryAdvice);
//		carePlan.setActivityRecommendations(activityRecommendations);
//		carePlan.setRehabilitationPlan(rehabilitationPlan);
//		carePlan.setHealthMonitoring(healthMonitoring);
//		carePlan.setPrecautions(precautions);
//		carePlan.setAdditionalAdvice(additionalAdvice);

		return aiResponse;
	}

	@Override
	public HealthReport generateHealthReport(Integer elderlyId, String reportType, String targetRole) {
		// 获取老人健康数据
		HealthData healthData = getElderlyHealthData(elderlyId);
		if (healthData == null) {
			return null;
		}

		// 构建提示词，包含老人的健康数据和报告类型
		StringBuilder prompt = new StringBuilder();
		prompt.append("请根据以下老人的健康数据，生成一份").append(getReportTypeInChinese(reportType))
			  .append("健康报告，报告面向").append(getTargetRoleInChinese(targetRole)).append("。\n\n");

		// 基本信息
		prompt.append("【基本信息】\n");
		prompt.append("姓名：").append(healthData.getName()).append("\n");
		prompt.append("性别：").append(healthData.getGender()).append("\n");
		prompt.append("年龄：").append(healthData.getAge()).append("\n");
		prompt.append("护理等级：").append(healthData.getLevelName()).append("\n\n");

		// 健康记录
		if (healthData.getHealthRecords() != null && !healthData.getHealthRecords().isEmpty()) {
			prompt.append("【健康记录】\n");
			// 根据报告类型筛选相关时间段的记录
			List<HealthRecordDTO> filteredRecords = filterHealthRecordsByReportType(healthData.getHealthRecords(), reportType);

			for (HealthRecordDTO record : filteredRecords) {
				prompt.append("记录时间：").append(record.getMeasureDate()).append("\n");
				prompt.append("血压：").append(record.getBloodPressure()).append("\n");
				prompt.append("心率：").append(record.getHeartRate()).append("\n");
				prompt.append("血糖：").append(record.getBloodSugar()).append("\n");
				if (record.getNote() != null && !record.getNote().isEmpty()) {
					prompt.append("备注：").append(record.getNote()).append("\n");
				}
				prompt.append("\n");
			}
		}

		// 医疗记录
		if (healthData.getMedicalRecords() != null && !healthData.getMedicalRecords().isEmpty()) {
			prompt.append("【医疗记录】\n");
			for (MedicalRecordDTO record : healthData.getMedicalRecords()) {
				prompt.append("疾病名称：").append(record.getDiseaseName()).append("\n");
				prompt.append("主要症状：").append(record.getMainSymptoms()).append("\n");
				prompt.append("疾病状态：").append(record.getDiseaseStatus()).append("\n");
				prompt.append("治疗方案：").append(record.getTreatmentPlan()).append("\n");
				prompt.append("当前用药：").append(record.getCurrentMedication()).append("\n");
				prompt.append("医生建议：").append(record.getDoctorAdvice()).append("\n\n");
			}
		}

		// 护理记录
		if (healthData.getNursingRecords() != null && !healthData.getNursingRecords().isEmpty()) {
			prompt.append("【护理记录】\n");
			// 根据报告类型筛选相关时间段的记录
			List<NursingRecordDTO> filteredRecords = filterNursingRecordsByReportType(healthData.getNursingRecords(), reportType);

			for (NursingRecordDTO record : filteredRecords) {
				prompt.append("记录时间：").append(record.getRecordTime()).append("\n");
				prompt.append("护理类型：").append(record.getCareType()).append("\n");
				prompt.append("护理内容：").append(record.getCareContent()).append("\n");
				prompt.append("风险评估：").append(record.getRisk()).append("\n\n");
			}
		}

		// 根据目标角色调整报告内容
		if ("family".equals(targetRole)) {
			prompt.append("\n请生成一份面向家属的健康报告，使用通俗易懂的语言，重点关注老人的生活状态、情绪变化和日常护理建议。\n");
		} else if ("doctor".equals(targetRole)) {
			prompt.append("\n请生成一份面向医生的健康报告，使用专业医学术语，重点关注医疗指标、疾病控制效果和治疗建议。\n");
		}

		prompt.append("\n请根据以上信息，生成一份结构化的健康报告，包括以下部分：\n");
		prompt.append("1. 报告摘要\n");
		prompt.append("2. 健康趋势\n");
		prompt.append("3. 护理重点\n");
		prompt.append("4. 风险评估\n");
		prompt.append("5. 建议\n");
		prompt.append("\n请严格遵守要点格式返回，每个要点用数字编号，并用中文冒号分隔，同时要点内容也要严格按照要点返回\n");

		// 调用AI生成健康报告
		String aiResponse = aiUtil.chat(prompt.toString(), elderlyId);

		// 创建健康报告对象
		HealthReport healthReport = new HealthReport();
		healthReport.setElderlyId(elderlyId);
		healthReport.setElderlyName(healthData.getName());
		healthReport.setReportType(reportType);
		healthReport.setGeneratedDate(new Date());
		healthReport.setContent(aiResponse);

		// 提取各部分内容
		String summary = extractSectionContent(aiResponse, "1", "报告摘要");
		String healthTrends = extractSectionContent(aiResponse, "2", "健康趋势");
		String carePoints = extractSectionContent(aiResponse, "3", "护理重点");
		String riskAssessment = extractSectionContent(aiResponse, "4", "风险评估");
		String recommendations = extractSectionContent(aiResponse, "5", "建议");

		healthReport.setSummary(summary);
		healthReport.setHealthTrends(healthTrends);
		healthReport.setCarePoints(carePoints);
		healthReport.setRiskAssessment(riskAssessment);
		healthReport.setRecommendations(recommendations);

		return healthReport;
	}

	/**
	 * 根据报告类型筛选健康记录
	 * @param records 所有健康记录
	 * @param reportType 报告类型
	 * @return 筛选后的健康记录
	 */
	private List<HealthRecordDTO> filterHealthRecordsByReportType(List<HealthRecordDTO> records, String reportType) {
		if (records == null || records.isEmpty()) {
			return new ArrayList<>();
		}

		// 获取当前时间
		Date now = new Date();

		// 根据报告类型筛选记录
		return records.stream()
				.filter(record -> {
					if (record.getMeasureDate() == null) {
						return false;
					}

					long diffInMillies = now.getTime() - record.getMeasureDate().getTime();
					long diffInDays = diffInMillies / (24 * 60 * 60 * 1000);

					switch (reportType) {
						case "daily":
							return diffInDays < 1; // 最近24小时
						case "weekly":
							return diffInDays < 7; // 最近一周
						case "monthly":
							return diffInDays < 30; // 最近一个月
						default:
							return true; // 默认返回所有记录
					}
				})
				.collect(Collectors.toList());
	}

	/**
	 * 根据报告类型筛选护理记录
	 * @param records 所有护理记录
	 * @param reportType 报告类型
	 * @return 筛选后的护理记录
	 */
	private List<NursingRecordDTO> filterNursingRecordsByReportType(List<NursingRecordDTO> records, String reportType) {
		if (records == null || records.isEmpty()) {
			return new ArrayList<>();
		}

		// 获取当前时间
		Date now = new Date();

		// 根据报告类型筛选记录
		return records.stream()
				.filter(record -> {
					if (record.getRecordTime() == null) {
						return false;
					}

					long diffInMillies = now.getTime() - record.getRecordTime().getTime();
					long diffInDays = diffInMillies / (24 * 60 * 60 * 1000);

					switch (reportType) {
						case "daily":
							return diffInDays < 1; // 最近24小时
						case "weekly":
							return diffInDays < 7; // 最近一周
						case "monthly":
							return diffInDays < 30; // 最近一个月
						default:
							return true; // 默认返回所有记录
					}
				})
				.collect(Collectors.toList());
	}

	/**
	 * 获取报告类型的中文描述
	 * @param reportType 报告类型
	 * @return 中文描述
	 */
	private String getReportTypeInChinese(String reportType) {
		switch (reportType) {
			case "daily":
				return "每日";
			case "weekly":
				return "每周";
			case "monthly":
				return "每月";
			default:
				return "";
		}
	}

	/**
	 * 获取目标角色的中文描述
	 * @param targetRole 目标角色
	 * @return 中文描述
	 */
	private String getTargetRoleInChinese(String targetRole) {
		switch (targetRole) {
			case "family":
				return "家属";
			case "doctor":
				return "医生";
			default:
				return "用户";
		}
	}
}
